package leetcode_1301_1400;

import java.util.Comparator;
import java.util.PriorityQueue;

public class LeeCode_1375 {
    public static void main(String[] args) {

    }
    private static int numTimesAllBlue(int[] flips) {
        int n = flips.length;
        PriorityQueue<Integer> queue = new PriorityQueue<>(Comparator.comparingInt(o -> flips[o]));
        for (int i = 0; i < n; i++) {
            queue.add(i);
        }
        int ans = 0, count = -1, max = -1;
        while (!queue.isEmpty()){
            Integer p = queue.poll();
            max = Math.max(max, p);
            count++;
            if (max == count)
                ans++;
        }
        return ans;
    }
}